<template>
  <section>
    <img class="bg" src="/static/images/pic3.png" alt="">
    <h3>{{question.questionName}}</h3>
    <div class="flex-col">
      <div class="line"></div>
      <img src="/static/images/tangle.png" alt="" class="tangle">
    </div>
    <div class="flex-row">
      <div v-for="(sline, index) in question.optionList" class="sline" :key="index"></div>
    </div>
    <div class="flex-row">
      <span v-for="(sline, index) in question.optionList" :key="index">{{sline.optionName}}</span>
    </div>
  </section>
</template>

<script>
import Draggabilly from 'Draggabilly'

export default {
  name: 'question',
  data () {
    return {
      title: 'type4',
      slines: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
      slines2: ['11我1', '111', '111', '111', '111', '111', '111', '111', '111', '111']
    }
  },
  mounted () {
    this.$nextTick(() => {
      this.initital()
    })
  },
  props: [
    'question'
  ],
  methods: {
    initital () {
      let elem = document.querySelector('.tangle')
      let draggie = new Draggabilly(elem, {
        axis: 'x',
        containment: '.flex-col',
        grid: [20, 20]
      })
      draggie.on('dragEnd', (event, pointer) => {
        console.log(event)
        console.log(pointer)
        this.$emit('next')
      })
    }
  }
}
</script>

<style lang="scss" scoped>
section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.flex-col {
  width: 730px;
  height: 250px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}
.bg {
  height: 100vw;
  width: 100vw;
}
.flex-row {
  width: 580px;
  display: flex;
  justify-content: space-between;
}
h3 {
  font-size: 40px;
  line-height: 60px;
  color: #999;
  margin: 30px auto;
}
.line {
  width: 580px;
  height: 20px;
  background-color: #ddd;
  border-radius: 10px;
}
.sline {
  width: 5px;
  height: 40px;
  background-color: #ddd;
  transform: translateY(-20px);
}
.tangle {
  position: absolute;
  width: 150px;
}
span {
  width: 15px;
  word-break: break-all;
  font-size: 24px;
}
</style>
